<%@ page import="com.apexedu.lbwsclient.document.LBDocumentWebService" %>
<%@ page import="com.apexedu.lbwsclient.document.LBDocumentService" %>
<%@ page import="com.apexedu.lbwsclient.document.DocumentResult" %>
<%@ page import="com.apexedu.lbwsclient.document.Document" %>
<%@ page import="javax.activation.DataHandler" %>
<%@ page import="java.io.InputStream" %>
<%@ page import="com.apexedu.util.FileUtil" %>
<%@ page import="java.io.IOException" %>
<%--
  LiveBos webservice 接口
  User: 杨建亮
  Date: 2015/7/3
  Time: 14:59
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%

    String SessionId = "83a8195113b047adda73e1e7c4b664f5";

    LBDocumentWebService lbDocumentWebService = new LBDocumentWebService();
    LBDocumentService lbDocumentService = lbDocumentWebService.getLBDocumentServiceImplPort();
    DocumentResult documentResult = lbDocumentService.getDocument(SessionId, "V_OA_SendDocument_NJCI_V3", "GDFJ", "303", "5");
    System.out.println("远程调用方法执行："+documentResult.getMessage());
    System.out.println("<br/>返回状态："+documentResult.getResult());
    Document document = documentResult.getDocument();
    String fileName = document.getFilename();
    long length = document.getLength();
    DataHandler dataHandler = document.getDocumentData();
    String contentType = dataHandler.getContentType();
    System.out.println("文件名："+fileName);
    System.out.println("类型："+contentType);
    System.out.println("长度："+length);
    try {
        InputStream inputStream = dataHandler.getInputStream();
        FileUtil.saveFile(inputStream, "", fileName, fileName);
        if(inputStream!=null){
            inputStream.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
%>
<html>
<head>
    <title></title>
</head>
<body>
<%
    out.println("<br/>文件名："+fileName);
    out.println("<br/>返回状态："+documentResult.getResult());
    out.println("<br/>返回状态："+documentResult.getMessage());
    out.println("<br/>类型："+contentType);
    out.println("<br/>长度："+length);
%>
</body>
</html>
